/**
 * BaseResponse.java
 *
 * @author liujie11
 * 
 * @date 2014-3-19
 * 
 * Copyright 2014 Baidu. All rights reserved. 
 */
package com.baidu.common.async_http;

import com.baidu.common.utils.Tools;

public class BaseResponse {
    final public static int ERR_CODE_NET = -1;
    final public static int ERR_CODE_USER_CANCEL = -2;
    final public static int ERR_CODE_JSON_PARSE = -3;
    final public static int ERR_CODE_GEO_PARSE = -4;
    final public static int ERR_CODE_SERVER = -5;
    final public static int RET_CODE_SUCCESS = 200;
    
    final public static String ERR_TEXT_JSON_PARSE = "解析数据失败";
    
    private int retcode = ERR_CODE_NET;
    private long size = 0;
    protected String retdesc = "";
    private Exception exception;
    
    public Exception getException() {
        return exception;
    }
    
    public void setException(Exception exception) {
        this.exception = exception;
    }
    
    public int getRetcode() {
        return retcode;
    }
    
    public void setRetcode(int retCode) {
        this.retcode = retCode;
    }
    
    public String getRetdesc() {
        return retdesc;
    }
    
    public void setRetdesc(String retDesc) {
        this.retdesc = retDesc;
    }
    
    public boolean isSuccess() {
        if (retcode == 200)
            return true;
        else
            return false;
    }
    
    public void setSize(long size) {
        this.size = size;
    }
    
    public long getSize() {
        return size;
    }
    
    public String getDebugInfo() {
        String result = "";
        if (!Tools.isEmpty(getRetdesc())) {
            // result += "(ErrorCode : " + getRetcode() + " : " +
            // getRetdesc()+")";
            result += "(" + getRetdesc() + ")";
        } else {
            // result += "(ErrorCode : " + getRetcode() + ")";
        }
        return result;
    }
}
